//
//  LBBaseTableViewController.swift
//  MicroBlog
//
//  Created by lj on 15/9/1.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class LSBaseTableViewController: UITableViewController {

    /// 用户登录标记
    var userlogon = LSUserAccountViewModel.sharedUserAccountViewModel.userLogon

    var visitorView: LSVisitorLoginView?
    
    override func loadView() {
        userlogon ? super.loadView() : setupVisitorView()
    }

    /// 设置访客视图
    private func setupVisitorView() {
    
        visitorView = LSVisitorLoginView()
        //替换根视图
        view = visitorView
        
        //添加左右两侧导航按钮
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorLoginViewWillRegister")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorLoginViewWillLogin")
        
        visitorView?.registerBtn.addTarget(self, action: "vistorLoginViewWillRegister", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginBtn.addTarget(self, action: "vistorLoginViewWillLogin", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
    
    //MARK:vistorLoginViewDelegate
    //访客登录
     @objc private func vistorLoginViewWillLogin(){
        
        let nav = UINavigationController(rootViewController: LSOAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
        
    }
         
    //访客注册
     @objc private func vistorLoginViewWillRegister(){
    
        printLog(__FUNCTION__)
    }
    
    
    

}
